package com.rhm.dataStructure.Leetcode;/**
 * @Author:759057893@qq.com Lyz
 * @Date: 2020/2/23 0:30
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2020/2/23 0:30
 *@Description:
 **/

class ListNode {

    int val ;
    ListNode next  ;
    public ListNode(int val){
        this.val = val;
    }
    public int getData() {
        return val;
    }

    @Override
    public String toString(){
        if(this.next==null){
            return  String.valueOf(this.val);
        }
        return this.val+ "->"+ this.next.toString();
    }


}
public class Code21 {
    public static void main(String[] args) {
       ListNode l1 = new ListNode(3);
        l1.val = 1;
       ListNode l2 = new ListNode(1);

    }
    public static ListNode mergeTwoLists(ListNode l1, ListNode l2) {
        if (l1 == null) {
            return l2;
        }
        else if (l2 == null) {
            return l1;
        }
        else if (l1.val < l2.val) {
            l1.next = mergeTwoLists(l1.next, l2);
            return l1;
        }
        else {
            l2.next = mergeTwoLists(l1, l2.next);
            return l2;
        }

    }
}
